package com.csdj.t309springboot.utils;
import java.util.Calendar;
/**
 * 计算距离今天24:00剩下的时间
 */
public class CalendarUtil {
    /**
     * 计算距离今天24:00剩下的时间, 单位秒
     * @return 秒
     */
    public static Integer computationTime() {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DAY_OF_YEAR, 1);
        // 改成这样就好了
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return Math.toIntExact((cal.getTimeInMillis() - System.currentTimeMillis()) / 1000);
    }

    public static void main(String[] args) {
        System.out.println(computationTime());
    }
}
